home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8853 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: mordred.cc.jyu.fi!news
  2. From: David Xia <dcx@amlibs.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: need help with functions
  5. Date: Mon, 26 Feb 1996 17:20:30 -0700
  6. Organization: Ameritech Library Services, Provo, UT 84604-5650. USA
  7. Message-ID: <31324E4E.7458@amlibs.com>
  8. References: <4grqta$mcb@ixnews3.ix.netcom.com>
  9. NNTP-Posting-Host: 192.206.159.189
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14. CC: dcx
  15.  
  16. wells wrote:
  17. >   I am learning c++, I wrote this program and I have a problem with it
  18. > that i cant figure out. I am doin this for my class in college. I am
  19. > using pass by reference in my functions, and  i have an error that
  20. > says something like.... "Get_payment is not suffieciently different
  21. > then Get_Payment", or something... I dont understand why.
  22.  
  23. The hint to the problem is right here.
  24. The compiler is confused your attempt(may even not intentionly) to 
  25. define two overloading functions.
  26.  
  27. > The program has that error and 4 other warnings, I am not worried
  28. > about the warnings, they have to do with my pow(x,x) statement being a
  29. > float and not an int. I am just worried about the function error. If
  30. > anyone can help I would greatly appreaciate it. And let me know what I
  31. > am doing wrong...
  32. > thanks very much..
  33. > edward
  34. > wells2@ix.netcom.com
  35. > I'm learning too.
  36.  
  37. >          // Function Prototype
  38. > void Get_Payment(float,float,int,float);                 // Function Prototype
  39.  
  40. > void Get_Payment(float &loan_amount,float &interest_rate,int
  41. > &number_of_payments,
  42. >                         float &payment)
  43.  
  44. If you change the  reference to float and int type to regular float and 
  45. int  as they are defined in the function declaration, the compiling 
  46. error message should go away.
  47.  
  48. The real problem is that the reference to the float is actually treated
  49. as same type to type float in compiling. So if you try to do function 
  50. overloading, the function signature should be different.  If not, then 
  51. the parameter list of the function should be the same.
  52.  
  53. Good luck
  54. -- 
  55. David Xia
  56.